package gui;

import javax.swing.ListModel;
import javax.swing.event.ListDataListener;
import portfolio.Market;

public class PortfolioList implements ListModel {
    
    private static PortfolioList instance = null;
    private Market marketSelected = null;
    
    private PortfolioList() 
    {
    
    }
    
    public static PortfolioList getInstance()
    {
        if(instance == null)
            instance = new PortfolioList();
        
        return instance;
    }

    public int getSize()
    {
        if(marketSelected == null)
            return 0;
                
        return PortfolioManager.getInstance().getPortfolioCount(marketSelected);
    }

    public Object getElementAt(int index)
    {
        return PortfolioManager.getInstance().getPortfolio(marketSelected, index);
    }

    public void addListDataListener(ListDataListener l) {
    }

    public void removeListDataListener(ListDataListener l) {
    }
    
    public void setMarketSelected(Market m)
    {
        marketSelected = m;
    }
    
    public Market getMarketSelected()
    {
        return marketSelected;
    }
    
}
